<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * VIP이용권 내역 컨트롤러
 */
class Vip_status extends CI_Controller {
	
	var $data = array();
	
	function __construct() {
		parent::__construct();
		$this->data['category']['main'] = $this->uri->segment(1);
		$this->data['category']['sub']  = $this->uri->segment(2);
		$this->data['sess_userinfo'] = $this->session->userdata('userinfo');

		$this->load->model('mypage/Member_model', 'member', TRUE);
	}

	// Default
	function index() {
		log_message('debug', "@@@@ Vip_status::index()");
		
		// 사용중인 패키지 정보
		$this->data['package'] = $this->member->get_member_package($this->data['sess_userinfo']['user_id']);
		$this->data['package']['start_dt'] = substr($this->data['package']['start_dt'], 0,4).'-'.substr($this->data['package']['start_dt'], 4,2).'-'.substr($this->data['package']['start_dt'], 6,2);
		$this->data['package']['end_dt']   = substr($this->data['package']['end_dt'], 0,4).'-'.substr($this->data['package']['end_dt'], 4,2).'-'.substr($this->data['package']['end_dt'], 6,2);
		
		// 사용중인 패키지에 해당되는 쿠폰 리스트
		$this->data['coupon_list'] = $this->member->select_member_package_coupon_list($this->data['package']['idx']);
		
		for ($i=0; $i < count($this->data['coupon_list']); $i++) {
			$this->data['coupon_list'][$i]['package_coupon_qty_str'] = $this->data['coupon_list'][$i]['package_coupon_qty'] > 10000 ? '무제한' : $this->data['coupon_list'][$i]['package_coupon_qty'].'장';
			$this->data['coupon_list'][$i]['qty_str'] = $this->data['coupon_list'][$i]['qty'] > 10000 ? '무제한' : $this->data['coupon_list'][$i]['qty'].'장';
		}

		// VIP이용권 선물 내역
		$this->data['vip_given_list'] = $this->member->select_vip_given_history_list($this->data['package']['idx']);
		
		// 가입상품 요약 정보
		$data['summary'] = $this->member->get_summary($this->data['sess_userinfo']['user_id']);
		$this->data['INC_SUMMARY'] = $this->load->view('inc/summary_v', $data, TRUE);

		
		$this->load->view('mypage/vip_status_v', $this->data);
	}
}

/* End of file vip_status.php */
/* Location: ./application/controllers/mypage/vip_status.php */